import java.util.*;

public class Main {
   
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();

        while (t > 0) {
            int sum = 0;
            int k = 1;
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            while (a != b) {
                k++;
                sum++;
                if (a < b)
                    a += k;
                else if (a > b)
                    a -= k;
                else
                    break;
            }
            System.out.println(sum);
            t--;
        }
    }
}